// -*- c++ -*-
/**************************************************************/
/*  This file is licensed from, and is a trade secret of:     */
/*                                                            */
/*    Mercury Computer Systems, Incorporated                  */
/*    199 Riverneck Road                                      */
/*    Chelmsford, Massachusetts 01824-2820                    */
/*    United States of America                                */
/*    Telephone + 1 978 256-1300                              */
/*                                                            */
/*  Refer to your Software License Agreement for provisions   */
/*  on use, duplication, or disclosure.                       */
/*  US. Government users and prime contractors are also       */
/*  governed by the following Data Rights Notice:             */
/*  Use, duplication or disclosure by the US. Government is   */
/*  subject to the provisions set forth in FAR 52.227-14 for  */
/*  restricted rights or other agency data rights provisions  */
/*  on commercial software and documentation, as applicable.  */
/*                                                            */
/*  This file: (a) was developed at private expense, and no   */
/*  part was developed with government funds, (b) is a        */
/*  trade secret of Mercury Computer Systems, Inc. for the    */
/*  purposes of the Freedom of Information Act, (c) is        */
/*  "commercial computer software" subject to limited         */
/*  utilization as provided in the above noted Software       */
/*  License Agreement and (d) is in all respects data         */
/*  belonging exclusively to Mercury Computer Systems, Inc..  */
/*                                                            */
/**************************************************************/

/******************************************************************/
/* Copyright (c) 1999-2003, Mercury Computer Systems, Inc.,       */
/* Chelmsford MA.,and all third party embedded software sources.  */
/* All rights reserved under the Copyright laws of US. and        */
/* international treaties.                                        */
/*                                                                */
/* Patent Pending                                                 */
/******************************************************************/


//$COPYRIGHT_END


#ifndef SCEOSLOADABLEMODULE_H__
#define SCEOSLOADABLEMODULE_H__

#ifdef WIN32
#pragma warning (disable : 4290)
#endif

/*
 * Abstract:
 *
 *     LoadableModule allows to dynamically load loadable modules
 *     (aka shared libraries or "DLLs") and to locate symbols
 *     within them.
 */

#include <SceOsDataTypes.h>
#include <string>

namespace SCE {
  namespace OS {

    class LoadableModule {
    public:
      /*
       * Constructor: Initializes the instance, but does not open a
       *              loadable module.
       */

      LoadableModule ()
	throw ();

      /*
       * Constructor: Initializes the instance, then calls
       *              open (fileName).
       */

      LoadableModule (const std::string & fileName)
	throw (std::string);

      /*
       * Destructor.
       *
       * An open loadable module must be closed before destruction.
       */

      ~LoadableModule ()
	throw ();

      /*
       * open(): Opens a loadable module.
       *
       * [in] fileName: The file name of a loadable module, according to
       *                local file name convention. The loadable module
       *                must be in a format that the local operating system
       *                considers appropriate.
       *
       * Only a single loadable module may be open at a time, per instance.
       */

      void open (const std::string & fileName)
	throw (std::string);

      /*
       * getSymbol(): Locates a symbol within the open loadable module.
       *
       * [in] symbolName: The name of the symbol.
       * [return]:        A generic pointer to the location of the
       *                  symbol within the loadable module. The pointer
       *                  can then be typecast to the expected type
       *                  (e.g., using static_cast<>()).
       */

      void * getSymbol (const std::string & symbolName)
	throw (std::string);

      /*
       * close(): Closes the open loadable module.
       *
       * Releases resources associated with the previously-openend
       * loadable module. Invalidates all pointers that were returned
       * by getSymbol().
       */

      void close ()
	throw (std::string);

    private:
      SCE::OS::uint64_t m_osOpaque[1];

    private:
      LoadableModule (const LoadableModule &);
      LoadableModule & operator= (const LoadableModule &);
    };

  }
}

#endif
